using UnityEngine;
using System.Collections;

public class NodeCreator : MonoBehaviour {

    static public AStar pathFinding; //esto no va a estar aca despues

    public GameObject nodeVisual;
    public bool createVisual = true;

    public int Rows = 20;
    public int Cols = 20;
	void Awake () 
    {
        pathFinding = new AStar();
        Vector3 upperLeft = new Vector3(this.transform.position.x - this.transform.localScale.x / 2
            , this.transform.position.y
            , this.transform.position.z + this.transform.localScale.z / 2);

        pathFinding.CreateNodes(upperLeft, transform.localScale.x, transform.localScale.z,50, 5, Rows, Cols, 1);

        //muestro un punto en cada nodo
        if (createVisual)
        {
            for (int i = 0; i < Rows; i++)
            {
                for (int j = 0; j < Cols; j++)
                {
                    StarNode node = pathFinding.GetNode(i, j);
                    if (node != null)
                    {
                        GameObject go = (GameObject)GameObject.Instantiate(nodeVisual);
                        go.transform.position = node.Position;
                    }
                }
            }
        }

	}

    // Update is called once per frame
    void Update()
    {
	
	}
}
